home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 10 Oct 2000
- //
- // Description:
- // This script provides an option box dialog for the diskCache command.
- //
- // Input Arguments:
- // boolean isCreationMode true - we are in creation mode
- // false - we are in deletion mode
- // boolean showOptionBox true - show the option box dialog
- // false - just execute the command
- //
- global proc disableDiskCacheAttrs(string $parent) {
- setParent $parent;
- string $showStartEnd = `radioButtonGrp -query -sl createDiskCacheTimeRange3`;
-
- if( $showStartEnd ) {
- floatFieldGrp -e -enable true createDiskCacheStartEndTime;
- } else {
- floatFieldGrp -e -enable false createDiskCacheStartEndTime;
- }
- }
-
- proc setOptionVars(int $forceFactorySettings)
- {
- if( $forceFactorySettings || !`optionVar -exists createDiskCacheTimeRange`)
- optionVar -intValue createDiskCacheTimeRange 2;
-
- if( $forceFactorySettings || !`optionVar -exists createDiskCacheStartTime`)
- optionVar -floatValue createDiskCacheStartTime 1;
-
- if( $forceFactorySettings || !`optionVar -exists createDiskCacheEndTime`)
- optionVar -floatValue createDiskCacheEndTime 10;
-
- if( $forceFactorySettings || !`optionVar -exists createDiskCacheSampling`)
- optionVar -intValue createDiskCacheSampling 1;
-
- if( $forceFactorySettings || !`optionVar -exists createDiskCacheSamplingRate`)
- optionVar -intValue createDiskCacheSamplingRate 1;
- }
-
- global proc createDiskCacheSetup (string $parent, int $forceFactorySettings)
- {
- setOptionVars($forceFactorySettings);
- setParent $parent;
-
- eval( "radioButtonGrp -e -sl 1 createDiskCacheTimeRange" +
- `optionVar -query createDiskCacheTimeRange` );
-
- floatFieldGrp -e
- -v1 `optionVar -query createDiskCacheStartTime`
- -v2 `optionVar -query createDiskCacheEndTime`
- createDiskCacheStartEndTime;
-
- radioButtonGrp -e
- -sl `optionVar -query createDiskCacheSampling`
- createDiskCacheSampling;
-
- intSliderGrp -e
- -v `optionVar -query createDiskCacheSamplingRate`
- createDiskCacheSamplingRate;
-
- disableDiskCacheAttrs $parent;
- }
-
- global proc createDiskCacheCallback(string $parent)
- {
- int $timeMode = 1;
-
- if( `radioButtonGrp -q -sl createDiskCacheTimeRange1` ) {
- $timeMode = 1;
- }
- else if( `radioButtonGrp -q -sl createDiskCacheTimeRange2` ) {
- $timeMode = 2;
- }
- else if( `radioButtonGrp -q -sl createDiskCacheTimeRange3` ) {
- $timeMode = 3;
- }
-
- optionVar -iv createDiskCacheTimeRange $timeMode;
- optionVar -fv createDiskCacheStartTime
- `floatFieldGrp -q -v1 createDiskCacheStartEndTime`;
- optionVar -fv createDiskCacheEndTime
- `floatFieldGrp -q -v2 createDiskCacheStartEndTime`;
-
- optionVar -iv createDiskCacheSampling
- `radioButtonGrp -query -sl createDiskCacheSampling`;
-
- optionVar -iv createDiskCacheSamplingRate
- `intSliderGrp -q -v createDiskCacheSamplingRate`;
- }
-
- global proc createDiskCachemcjCallback(string $parent)
- {
- createDiskCacheCallback $parent;
- performDiskCache true false mcj;
- }
-
- proc creationOptionBox(string $cacheType)
- {
- // Name of the command for this option box
- //
- string $commandName = "createDiskCache";
-
- // Build the option box "methods"
- //
- string $callback = ($commandName + $cacheType + "Callback ");
- string $setup = ($commandName + "Setup");
-
- // STEP 1: Get the option box.
- // ============================
- //
- // The value returned is the name of the layout to be used as
- // the parent for the option box UI.
- //
- string $layout = getOptionBox();
- setParent $layout;
-
- // STEP 2: Pass the command name to the option box.
- // =================================================
- //
- // Any default option box behaviour based on the command name is set
- // up with this call. For example, updating the 'Help' menu item with
- // the name of the command.
- //
- setOptionBoxCommandName($commandName);
-
- // STEP 3: Activate the default UI template.
- // ==========================================
- //
- // Activate the default UI template so that the layout of this
- // option box is consistent with the layout of the rest of the
- // application.
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // STEP 4: Create option box contents.
- // ===================================
- //
- // This, of course, will vary from option box to option box.
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -scr true -tv false;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- // Create the widgets for this option box
- //
- radioButtonGrp
- -label "Cache Time Range" -nrb 1
- -l1 "Render Globals"
- -cc ( "disableDiskCacheAttrs " + $parent )
- createDiskCacheTimeRange1;
-
- radioButtonGrp
- -label "" -nrb 1
- -scl createDiskCacheTimeRange1
- -cc ( "disableDiskCacheAttrs " + $parent )
- -l1 "Time Slider"
- createDiskCacheTimeRange2;
-
- radioButtonGrp
- -label "" -nrb 1
- -scl createDiskCacheTimeRange1
- -l1 "Start/End"
- -cc ( "disableDiskCacheAttrs " + $parent )
- createDiskCacheTimeRange3;
-
- floatFieldGrp -label "Start/End" -nf 2
- createDiskCacheStartEndTime;
-
- separator -h 5 -style "none";
-
- radioButtonGrp -nrb 2 -l "Sampling" -l1 "Over" -l2 "Under"
- createDiskCacheSampling;
-
- intSliderGrp -l "Rate" -min 1 -max 5 -fmn 1 -fmx 100 -value 1
- createDiskCacheSamplingRate;
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- setUITemplate -popTemplate;
-
- // Step 6: Customize the buttons.
- // ==============================
- //
- // Provide more descriptive labels for the buttons. This is not
- // necessary, but in some cases, for example, a button labelled
- // 'Create' may be more meaningful to the user than one labelled
- // 'Apply'.
- //
- // Disable those buttons that are not applicable to the option box.
- //
- // Attach actions to those buttons that are applicable to the option
- // box. Note that the 'Close' button has a default action attached
- // to it that will hide the window. If a a custom action is
- // attached to the 'Close' button then be sure to call the 'hide the
- // option box' procedure within the custom action so that the option
- // box is hidden properly.
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit -label "Create"
- -command ($callback + " " + $parent)
- $applyBtn;
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- // Don't use $callback since that has cacheType specific
- // stuff in it and will cause the "save" button to execute
- // the createDiskCache proc for that cacheType!
- //
- -command ($commandName+"Callback" + " " + $parent + "; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button
- string $resetBtn = getOptionBoxResetBtn();
- int $resetToDefaults = 1;
- button -edit
- -command ($setup + " " + $parent + " " + $resetToDefaults)
- $resetBtn;
-
- // Step 7: Set the option box title.
- // =================================
- //
- setOptionBoxTitle("Create Disk Cache Options");
-
- // Step 8: Customize the 'Help' menu item text.
- // ============================================
- //
- setOptionBoxHelpTag( "CreateJiggleDiskCache" );
-
- // Step 9: Set the current values of the option box.
- // =================================================
- //
- eval ($setup + " " + $parent + " " + 0);
-
- // Step 10: Show the option box.
- // =============================
- //
- showOptionBox();
- }
-
- proc string creation(string $cacheType)
- {
- string $cmd;
-
- // do nothing if therre is no diskCache
- string $allDiskCaches[] = `ls -type "diskCache"`;
- if( size($allDiskCaches) < 1 ) {
- string $msg = "No diskCache nodes found. No caches to create.";
- warning $msg;
- return $cmd;
- }
-
- // Verify all diskCache files have unique names
- int $n, $m;
- for($n = 1; $n < size($allDiskCaches); $n++) {
- string $cacheName = `getAttr ($allDiskCaches[$n] + ".cacheName")`;
- if( size($cacheName) == 0 )
- $cacheName = `getAttr ($allDiskCaches[$n] + ".hiddenCacheName")`;
- for( $m = 0; $m < $n; $m++) {
- string $preCacheName = `getAttr ($allDiskCaches[$m] + ".cacheName")`;
- if( size($preCacheName) == 0 )
- $prevCacheName = `getAttr ($allDiskCaches[$m] + ".hiddenCacheName")`;
- if( $cacheName == $preCacheName ) {
- string $msg = ( "Disk cache is not created because " +
- $allDiskCaches[$m] +
- " and " +
- $allDiskCaches[$n] +
- " have disk cache name conflict, and one of them has to be renamed." );
- error $msg;
- return $cmd;
- }
- }
- }
-
- verifyWorkspaceFileRule( "diskCache", "data" );
-
- string $frameRangeOption = "Time Slider";
- int $rangeMode = `optionVar -query createDiskCacheTimeRange`;
- if( $rangeMode == 1 ) {
- $frameRangeOption = "Render Globals";
- } else if( $rangeMode == 2 ) {
- $frameRangeOption = "Time Slider";
- } else if( $rangeMode == 3 ) {
- $frameRangeOption = "Start/End";
- }
-
- string $samplingType = "";
- if( `optionVar -query createDiskCacheSampling` == 1 ) {
- $samplingType = "-os";
- }
-
- float $diskCacheStartTime =`optionVar -query createDiskCacheStartTime`;
- float $diskCacheEndTime =`optionVar -query createDiskCacheEndTime`;
- int $samplingRate =`optionVar -query createDiskCacheSamplingRate`;
-
- if( $frameRangeOption == "Start/End" ) {
- $cmd = "diskCache" + " -frt \"" + $frameRangeOption + "\"" +
- " -st " + $diskCacheStartTime +
- " -et " + $diskCacheEndTime +
- " " + $samplingType +
- " -ct " + $cacheType +
- " -sr " + $samplingRate;
- } else {
- // $frameRangeOption == "Time Slider" or "Render Globals"
- $cmd = "diskCache" + " -frt \"" + $frameRangeOption + "\"" +
- " " + $samplingType +
- " -ct " + $cacheType +
- " -sr " + $samplingRate;
- }
-
- // Only affect enabled cache nodes.
- //
- $cmd = $cmd + " -enabledCachesOnly ";
-
- return $cmd;
- }
-
- global proc string performDiskCache( int $isCreation, int $showOptionBox, string $cacheType )
- {
- if( $cacheType != "mcj" ) {
- error( "Use performFluidsDiskCache for mcfi and mcfp cache types." );
- return "";
- }
-
- string $cmd = "";
- if( $isCreation ) {
- if( $showOptionBox )
- creationOptionBox $cacheType;
- else {
- setOptionVars(false);
- $cmd = creation($cacheType);
- evalEcho($cmd);
- }
- } else { // is deletion
- // delete all disk cache files
- $cmd = "diskCache -d";
- evalEcho($cmd);
- }
- return $cmd;
- }
-
-